<?php
set_include_path(realpath('./library'). PATH_SEPARATOR . get_include_path()); 
/*
require_once "library/Respect/Validation/Exceptions/ComponentException.php";
require_once "library/Respect/Validation/Validatable.php";
require_once "library/Respect/Validation/Rules/AbstractRule.php";
require_once "library/Respect/Validation/Rules/Numeric.php";
require_once "library/Respect/Validation/Rules/AbstractFilterRule.php";
require_once "library/Respect/Validation/Rules/AbstractCtypeRule.php";
require_once "library/Respect/Validation/Rules/Alnum.php";
require_once "library/Respect/Validation/Rules/AbstractComposite.php";
require_once "library/Respect/Validation/Rules/AllOf.php";
require_once "library/Respect/Validation/Validator.php";*/
use Respect\Validation\Validator as v; 

// Simple Validation 

$number = 123;
if(v::numeric()->validate($number))
	echo $number; //true 

// Chained Validation 

$usernameValidator = v::alnum()->noWhitespace()->length(1,15);
$usernameValidator->validate('alganet'); //true 

// Validating Object Attributes 

$user = new stdClass;
$user->name = 'Alexandre';
$user->birthdate = '1987-07-01'; 

// Validate its attributes in a single chain: 

$userValidator = v::attribute('name', v::string()->length(1,32))
                  ->attribute('birthdate', v::date()->minimumAge(18)); 

if($userValidator->validate($user))
	print_r($user); //true